package com.uoko.demo.controller;

import com.uoko.demo.domain.entity.ResourceRoleEntity;
import com.uoko.demo.service.ResourceRoleService;
import com.uoko.demo.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;


/**
 * @author shaohua
 * @email shaohua@uoko.com
 * @date 2018-06-12 16:12:25
 */
@RestController
@RequestMapping("demo/resourcerole")
public class ResourceRoleController {
    @Autowired
    private ResourceRoleService resourceRoleService;


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id) {
        ResourceRoleEntity resourceRole = resourceRoleService.selectById(id);

        return R.ok().put("resourceRole", resourceRole);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody ResourceRoleEntity resourceRole) {
        resourceRoleService.insert(resourceRole);

        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    public R update(@RequestBody ResourceRoleEntity resourceRole) {
        resourceRoleService.updateAllColumnById(resourceRole);//全部更新

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody Integer[] ids) {
        resourceRoleService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
